package com.cml.common.serializable;

import com.cml.common.dto.message.FetchSlotsAllocationResponse;
import com.cml.common.dto.entity.Message;
import com.cml.common.util.SocketChannelParseStringUtil;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

/**
 * 姓名：陈茂林
 * 时间：2023/10/18 14:26
 * 描述：
 */
public class FetchSlotsAllocationResponseSerializable extends MessageSerializable {
    public void doBuildEncoderMessage(Message message, ByteBuffer byteBuffer) {
        FetchSlotsAllocationResponse fetchSlotsAllocationResponse = (FetchSlotsAllocationResponse) message;
        SocketChannelParseStringUtil.stringDataBuild(byteBuffer,fetchSlotsAllocationResponse.getSoltMetadataList());
    }

    public Message doBuildDecoderMessage(SocketChannel socketChannel) throws IOException {
        FetchSlotsAllocationResponse fetchSlotsAllocationResponse =new FetchSlotsAllocationResponse();
        fetchSlotsAllocationResponse.setSoltMetadataList(SocketChannelParseStringUtil.parse(socketChannel));
        return fetchSlotsAllocationResponse;
    }
}
